<import file="block/common.html" name="url" :tpl_cfg="['urlName'=>'系统信息设置']"/>
<div class="layui-fluid">
    <div class="layui-form">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
              <li class="layui-this">系统设置</li>
              <li>上传设置</li>
              <li>缓存设置</li>
              <li>模板设置</li>
            </ul>

    <div class="layui-tab-content">
        <!--系统-->
        <div class="layui-tab-item layui-show">
            <div class="layui-form-item" style="margin-top:10px;padding-top: 10px;">
                <label class="layui-form-label required">系统名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="sitename" lay-verify="required" lay-reqtext="系统名称不能为空" placeholder="请输入系统名称"  value="<{$config['siteinfo']['sitename']}>" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">系统域名</label>
                <div class="layui-input-inline" style="width:280px;">
                    <input type="text" name="siteurl" lay-verify="required" lay-reqtext="系统域名不能为空" placeholder="请输入系统域名"  value="<{$config['siteinfo']['siteurl']}>" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">META关键词</label>
                <div class="layui-input-block">
                    <textarea name="keywords" class="layui-textarea" placeholder="多个关键词用英文状态 , 号分割"><{$config['siteinfo']['keywords']}></textarea>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">META描述</label>
                <div class="layui-input-block">
                    <textarea name="descript" class="layui-textarea"><{$config['siteinfo']['descript']}></textarea>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label required">版权信息</label>
                <div class="layui-input-block">
                    <textarea name="copyright" class="layui-textarea"><{$config['siteinfo']['copyright']}></textarea>
                </div>
            </div>
          </div>
    <!--上传-->
    <div class="layui-tab-item">
        <fieldset class="layui-elem-field" style="margin-top: 10px;padding-top: 10px;">
            <legend>图片上传</legend>
        <div class="layui-form-item">
            <label class="layui-form-label">最大上传</label>
            <div class="layui-input-inline" style="width: 80px;">
                <input type="text" name="imguploadsize" lay-verify="number" value="<{$config['upload']['imguploadsize']}>" class="layui-input">
            </div>
            <div class="layui-input-inline layui-input-company" style="width: 30px;line-height: 35px;">KB</div>
            <div class="layui-form-mid layui-word-aux">1 M = 1024 KB</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">上传类型</label>
            <div class="layui-input-inline" style="width:380px;">
                <input type="text" name="imguploadext" value="<{$config['upload']['imguploadext']}>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">如：.jpg|.png|.jpeg|.gif</div>
        </div>
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label required">开启缩略图</label>
            <div class="layui-input-inline" style="height: 38px;line-height: 38px;">
                <input type="checkbox" name="thumbON" lay-skin="switch" lay-filter="thumbON" lay-text="ON|OFF" value="1" <?php echo $config['upload']['thumbON']==1 ?'checked':'';?>>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">缩略最宽</label>
            <div class="layui-input-inline" style="width: 80px;">
                <input type="text" name="maxWidth" value="<{$config['upload']['maxWidth']}>" class="layui-input">
            </div>
            <div class="layui-input-inline layui-input-company" style="width: 30px;line-height: 35px;">px</div>
            <div class="layui-form-mid layui-word-aux">如：1100</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">缩略最高</label>
            <div class="layui-input-inline" style="width: 80px;">
                <input type="text" name="maxHeight" value="<{$config['upload']['maxHeight']}>" class="layui-input">
            </div>
            <div class="layui-input-inline layui-input-company" style="width: 30px;line-height: 35px;">px</div>
            <div class="layui-form-mid layui-word-aux">如：900</div>
        </div>
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label required">开启水印</label>
            <div class="layui-input-inline"  style="height: 38px;line-height: 38px;">
                <input type="checkbox" name="waterON" lay-skin="switch" lay-filter="waterON" lay-text="ON|OFF" value="1" <?php echo $config['upload']['waterON']==1 ?'checked':'';?>>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-inline">
               <img id="waterImgSrc" src="/res/img/waterimg/logo.png">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">图片位置</label>
            <div class="layui-input-block">
                <span style="height: 38px;line-height: 38px;">/res/img/waterimg/logo.png</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">水印位置</label>
            <div class="layui-input-inline">
                <select name="waterPos" lay-verify="">
                    <option value="0" <?php if($config['upload']['waterPos'] == 0){echo 'selected';}?>>随机位置</option>
                    <option value="1" <?php if($config['upload']['waterPos'] == 1){echo 'selected';}?>>左上</option>
                    <option value="2" <?php if($config['upload']['waterPos'] == 2){echo 'selected';}?>>上中</option>
                    <option value="3" <?php if($config['upload']['waterPos'] == 3){echo 'selected';}?>>右上</option>
                    <option value="4" <?php if($config['upload']['waterPos'] == 4){echo 'selected';}?>>左中</option>
                    <option value="5" <?php if($config['upload']['waterPos'] == 4){echo 'selected';}?>>正中</option>
                    <option value="6" <?php if($config['upload']['waterPos'] == 6){echo 'selected';}?>>右中</option>
                    <option value="7" <?php if($config['upload']['waterPos'] == 7){echo 'selected';}?>>左下</option>
                    <option value="8" <?php if($config['upload']['waterPos'] == 8){echo 'selected';}?>>下中</option>
                    <option value="9" <?php if($config['upload']['waterPos'] == 9){echo 'selected';}?>>右下</option>
                  </select>
            </div>
        </div>
    </fieldset>
    <fieldset class="layui-elem-field" style="margin-top:20px;padding-top: 10px;">
        <legend>附件上传</legend>
        <div class="layui-form-item">
            <label class="layui-form-label">最大上传</label>
            <div class="layui-input-inline" style="width: 80px;">
                <input type="text" name="attuploadsize" lay-verify="number" value="<{$config['upload']['attuploadsize']}>" class="layui-input">
            </div>
            <div class="layui-input-inline layui-input-company" style="width: 30px;line-height: 35px;">KB</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">上传类型</label>
            <div class="layui-input-inline" style="width:380px;">
                <input type="text" name="attuploadext" value="<{$config['upload']['attuploadext']}>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">如：.doc|.docx|.zip|.7z|.zip|.xls|.xlsx</div>
        </div>
    </fieldset>
    <fieldset class="layui-elem-field" style="margin-top:20px;padding-top: 10px;">
        <legend>视频上传</legend>
        <div class="layui-form-item">
            <label class="layui-form-label">最大上传</label>
            <div class="layui-input-inline" style="width: 80px;">
                <input type="text" name="videouploadsize" lay-verify="number" value="<{$config['upload']['videouploadsize']}>" class="layui-input">
            </div>
            <div class="layui-input-inline layui-input-company" style="width: 30px;line-height: 35px;">KB</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">上传类型</label>
            <div class="layui-input-inline" style="width:380px;">
                <input type="text" name="videouploadext" value="<{$config['upload']['videouploadext']}>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">如：.mp4|.avi|.mp3</div>
        </div>
    </fieldset>
</div>
<!--缓存-->
<div class="layui-tab-item">
    <fieldset class="layui-elem-field" style="margin-top: 10px;padding-top: 10px;">
        <legend>首页静态</legend>
        <div class="layui-form-item">
            <label class="layui-form-label required">开启静态</label>
            <div class="layui-input-inline"  style="height: 38px;line-height: 38px;">
                <input type="checkbox" name="indexhtml" lay-skin="switch" lay-filter="indexhtml" lay-text="ON|OFF" value="1" <?php echo $config['cache']['indexhtml']==1 ?'checked':'';?>>
            </div>
            <div class="layui-form-mid layui-word-aux">开启后，首页上的数据缓存仍然起作用</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">缓存时间</label>
            <div class="layui-input-inline">
                <input type="text" name="indexhtmltime" lay-verify="required" lay-reqtext="首页静态缓存时间不能为空" placeholder="请输入首页静态缓存时间"  value="<{ $config['cache']['indexhtmltime'] }>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">单位秒，如 600</div>
        </div>
    </fieldset>

    <fieldset class="layui-elem-field" style="margin-top:20px;padding-top: 10px;">
        <legend>访问统计</legend>
        <div class="layui-form-item">
            <label class="layui-form-label required">开启缓存</label>
            <div class="layui-input-inline" style="height: 38px;line-height: 38px;">
                <input type="checkbox" name="visitscache" lay-skin="switch" lay-filter="visitscache" lay-text="ON|OFF" value="1" <?php echo $config['cache']['visitscache']==1 ?'checked':'';?>>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">写入缓存计数</label>
            <div class="layui-input-inline">
                <input type="text" name="visitsnum"  value="<{ $config['cache']['visitsnum'] }>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">达到多少计数量后更新缓存，单位秒，如 51（建议设置成奇数），可根据访问量进行设置，访问量越大数字设置越大，默认51</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">写入缓存时间</label>
            <div class="layui-input-inline" >
                <input type="text" name="visitstime"  value="<{ $config['cache']['visitstime'] }>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">根据访问量，建议此值设置大一些，防止计数缓存自动清除，缓存时间，单位秒，如 6000</div>
        </div>
    <hr>
        <div class="layui-form-item">
            <label class="layui-form-label required">调用缓存时间</label>
            <div class="layui-input-inline" >
                <input type="text" name="visitsshowtime"  value="<{ $config['cache']['visitsshowtime'] }>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">前台调用访问量的缓存时间，单位秒，如 600</div>
        </div>

    </fieldset>

    <fieldset class="layui-elem-field" style="margin-top:20px;padding-top: 10px;">
        <legend>按角色统计发布内容数量</legend>
        <div class="layui-form-item">
            <label class="layui-form-label required">缓存时间</label>
            <div class="layui-input-inline" style="height: 38px;line-height: 38px;">
                <input type="text" name="publishtime"  value="<{ $config['cache']['publishtime'] }>" class="layui-input" lay-verify="required" lay-reqtext="缓存时间不能为空">
            </div>
            <div class="layui-form-mid layui-word-aux">单位：天，此项统计极耗系统资源，建议设置时间长点，如：1天，2天等</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">统计范围</label>
            <div class="layui-input-inline">
                <input type="radio" name="publishyear" value="1" title="全部" <?php echo $config['cache']['publishyear']==1 ?'checked':'';?>>
                <input type="radio" name="publishyear" value="0" title="本年" <?php echo $config['cache']['publishyear']==0 ?'checked':'';?>>
              </div>
            <div class="layui-form-mid layui-word-aux">只统计本年或者全部数据库数据</div>
        </div>
    </fieldset>

    <fieldset class="layui-elem-field" style="margin-top:20px;padding-top: 10px;">
        <legend>后台缓存设置</legend>
        <div class="layui-form-item">
            <label class="layui-form-label required">发布统计缓存时间</label>
            <div class="layui-input-inline" style="height: 38px;line-height: 38px;">
                <input type="text" name="publishcachetime"  value="<{ $config['cache']['publishcachetime'] }>" class="layui-input" lay-verify="required" lay-reqtext="发布统计缓存时间不能为空">
            </div>
            <div class="layui-form-mid layui-word-aux">单位：秒，此项统计极耗系统资源，建议设置时间长点，如：86400为天等</div>
        </div>
       
    </fieldset>
    </div>

    <!--模板设置-->
    <div class="layui-tab-item">
        
            <div class="layui-form-item">
                <label class="layui-form-label required">主页模板</label>
            <div class="layui-input-inline layui-col-md4">
					<select name="indextheme" lay-verify="">
					 <option value="">默认模板</option>
					<?php foreach($templist as $key=>$vo){?>
					  <option value="<{$vo}>" <?php if($config['theme']['indextheme'] == $vo){echo "selected";} ?>><{$vo}></option>
					<?php }?>
					</select>  
            </div>
            <div class="layui-form-mid layui-word-aux">模板位置在: \app\index\view\default\index\ 目录下</div>
            </div>
    </div>

    <!--模板设置 END-->


</div>
</div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                <?php echo SysRolCk("siteconfig_edit")?'<button class="layui-btn" lay-submit lay-filter="setting"><i class="layui-icon">&#x1005;</i>'.lang('save').'</button>':''; ?> 
                </div>
            </div>
</div>
</div>

<script>
    layui.define(function () {
        var form = layui.form, 
        layer = layui.layer,
        $ = layui.jquery, 
        element = layui.element;

        form.render();

        //监听提交
		form.on('submit(setting)', function (data) {
            var postValue = data.field;
            //console.log(postValue.indexhtml);  
			$.post('<{CAUrl("system","edit")}>',postValue,function(res){
                if(res.status == 1){
                    if(postValue.indexhtml != 1){
                        //静态首页取消后，删除静态文件！
                        <?php DelFile("index.html");?>
                    }
                    layer.msg(res.info, {icon: 1, time: 1000}, function(){
                        loadMain('<{CAUrl("system","index")}>');
                    });
                }else{
                    layer.msg(res.info, {icon: 2, anim: 6, time: 5000});
                }
            });
            return false;
		});
    });
</script>
